<div class="box white_bg">

<?
if (file_exists(APP_PATH."/public/ufiles/" . $this->viewParams['u']->id . "/images/original/avatar/avatar.jpg"))
{
	$avatar_image = "/public/ufiles/" . $this->viewParams['u']->id ."/images/%s/avatar/avatar.jpg";
}
?>        
<? if (isset($avatar_image)) :?>
<img src="<?=sprintf($avatar_image, "xxsmall");?>" alt="avatar"/>
<?else :?>
<img src="/public/ufiles/0/images/small/avatar/avatar.jpg" alt="avatar"/> (<?=t(469) ?>)
<?endif ?>
 <?=t(438) ?> <?=$this->viewParams['u']->name ?> (#<?=$this->viewParams['u']->id ?>) 

<table>

<tr> <td><b><?=t(470) ?></b></td>
<td><?=$this->viewParams['u']->mail ?></td>
</tr>

<tr> <td><b><?=t(461) ?></b></td>
<td><?=$this->viewParams['u']->fullname ?></td>
</tr>

<tr> <td><b><?=t(462) ?></b></td>
<td><?=$this->viewParams['u']->gender ?></td>
</tr>


<tr> <td><b><?=t(81) ?></b></td>
<td> <?=$this->viewParams['u']->language ?></td>
</tr>

<tr> <td><b><?=t(824) ?></b></td>
<td><a href="<?=$this->viewParams['u']->website ?>"><?=$this->viewParams['u']->website ?></a></td>
</tr>

<tr> <td><b><?=t(460) ?></b></td>
<td><?=$this->viewParams['u']->country ?></td>
</tr>
</table>

<br/>
<b> <?=t(429) ?>: </b> <?=$this->viewParams['u']->signature ?>

 <div style="padding-top:15px" class="box" id="follow">
<?
    $auth = Zend_Auth::getInstance();
    $uIdentity = $auth->getIdentity();
?>
<?if (is_null($uIdentity)) :?>
<a href="<?=$this->hvnUrl(array('module' => 'user', 'action' => 'login'), 'account'); ?>"> 
<?=t(2000);?> 
</a>
<?elseif ($uIdentity != $this->viewParams['u']->id) :?>
<button class="ajax_button" name='1' href="<?=$this->hvnUrl(array('module' => 'user', 'controller' => 'ajax', 'action' => 'set-user-followship'), 'generic'); ?>"><?=t(2001); ?> </button>
<label></label>
<script type="text/javascript">
$(function() {
    $.getJSON("<?=$this->hvnUrl(array('module' => 'user', 'controller' => 'ajax', 'action' => 'get-user-followship'), 'generic'); ?>",
        {uid: <?=$this->viewParams['u']->id?>}, 
        function(json){
            if (json.followed)
               $("#follow label").html('<?=$this->viewParams['u']->name?>' + '<?=t(2003)?>');
            if (json.follows) //now set the unfollow button
               $("#follow button").html('<?=t(2002) ?>').attr('name', 0); //unfollow me
            else
               $("#follow button").html('<?=t(2001) ?>').attr('name', 1); //follow me


            $(".ajax_button").click(function(){
                $.getJSON($(this).attr('href'), 
                    {uid: "<?=$this->viewParams['u']->id?>", followship: $(this).attr('name')}, 
                    function(json){
                        if (json.success == 1)
                        {
                            $("#follow button").html('<?=t(2002) ?>').attr('name', 0); //unfollow me
                        }
                        else if (json.success == 2)
                        {
                            $("#follow button").html('<?=t(2001) ?>').attr('name', 1); //follow me
                        }
                        else
                        {
                            alert("Something wrong");
                        }
                });
            });
            
        });
    /*
    $(".ajax_button").click(function(){
        alert( $(this).attr('href') );
        $.get($(this).attr('href'), {id: "<?=$this->viewParams['u']->id?>"}, function(data){
            alert("Data returned " + data);
        });
    });
    */
});

</script>
<?endif?>
</div>


</div>